package com.alibaba.citrus.cr.unified.inventory.model.enums;

import jdk.internal.dynalink.beans.StaticClass;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wanwy
 * @description 单据原因
 */
public enum DocumentReasonEnum {

    CUSTOMER_ADD_ORDER("001","客户加单"),
    CHEESE_ORDER_DOMESTIC_ORDER("002","奶酪订单-内销订单"),
    DISTRIBUTE_TRIAL_DRINKS_ACCORDING_TO_NORMAL_SALES("003","按正常销售发放试饮品"),
    CUSTOMER_RETURNS("004","客户退货"),
    ERROR_IN_PRICE_MASTER_DATA_MAINTENANCE("005","价格主数据维护有误"),
    CARGO_DAMAGE("006","货损"),
    PURCHASE_GIVE("007","买赠"),
    RETURN_OF_EXPIRED_PRODUCTS("A01","过期品退货"),
    DAMAGED_RETURN("A02","破损退货"),
    RETURN_AND_SUPPLEMENTARY_DISPLAY("A03","退货补陈列"),
    RETURN_TO_MAKE_UP_INVENTORY_LOSS("A04","退货补盘亏"),
    PRODUCT_QUALITY_RETURN("A05","产品质量退货"),
    RETURN_COMPENSATION("A06","退货补赔偿"),
    RETURN_WITH_WRONG_LOCK_CODE("A07","锁码错码退货"),
    TEMPORARY_GOODS_RETURN("A08","临期品退货"),
    RETURN_OF_LARGE_INVENTORY_GOODS("A09","大库存商品退货"),
    RETURN_CONVERT_TO_TEST_DRINK("A10","退货转试饮品"),
    OUTDOOR_SALES_RETURN("A11","户外销售退货"),
    RETURN_FOR_OTHER_REASONS("A12","其他原因退货"),
    MILK_CARD_EXCHANGE("A13","奶卡兑换"),
    PATCHING("A14","补残"),
    LOGISTICS_RETURN_POD_RETURN("A15","物流退货(POD退货)"),
    OTHER_REPLENISHMENT("A16","其他补货"),
    PERIPHERAL_SYSTEM_RETURN_REQUEST("Y98","外围系统退货请求"),
    SALES_OF_RAW_MATERIALS_SCRAP_OTHERS("Y99","原材料/废品/其他等销售"),
    MENGNIU_HYPOTHERMIA("Z1","蒙牛低温"),
    DANONE_LOW_TEMPERATURE("Z2","达能低温");

    private String code;

    private String desc;

    DocumentReasonEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 通过code获取枚举
     *
     * @param code code
     * @return by code
     */
    public static DocumentReasonEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (DocumentReasonEnum documentReasonEnum : values()) {
            if (StringUtils.equalsIgnoreCase(code, documentReasonEnum.getCode())) {
                return documentReasonEnum;
            }
        }
        return null;
    }

    /**
     * 获取所有的单据原因枚举
     * @return
     */
    public static List<DocumentReasonEnum> queryEnum(){
        List<DocumentReasonEnum> list = new ArrayList<>();
        for (DocumentReasonEnum documentReasonEnum : values()) {
            list.add(documentReasonEnum);
        }
        return list;
    }
}
